package com.squirrel.common.controller;

import com.squirrel.common.annotation.AuthToken;
import com.squirrel.common.param.userVideo.OperationParam;
import com.squirrel.common.response.ResponseResult;
import com.squirrel.common.response.ResponseResultUtils;
import com.squirrel.common.service.UserSubscriptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * UserSubscriptionController 用户关注前端控制器
 * </p>
 *
 * @author 关远键
 * @since 2021/11/11 16:06
 */
@RestController
@RequestMapping("/api/user-subscription")
@AuthToken
@Api(tags = "用户关注控制器")
public class UserSubscriptionController {

    @Autowired
    private UserSubscriptionService usService;

    @GetMapping("/getIdols/{userId}")
    @ApiOperation("偶像")
    public ResponseResult getIdols(@PathVariable("userId") Integer userId) {
        return ResponseResultUtils.success(usService.getIdols(userId));
    }

    @GetMapping("/getFans/{userId}")
    @ApiOperation("粉丝")
    public ResponseResult getFans(@PathVariable("userId") Integer userId) {
        return ResponseResultUtils.success(usService.getFans(userId));
    }

    @GetMapping("/getCollect/{userId}")
    @ApiOperation("收藏")
    public ResponseResult getCollect(@PathVariable("userId") Integer userId) {
        return ResponseResultUtils.success(usService.getFans(userId));
    }

    @PostMapping("/add")
    @ApiOperation("添加关注")
    @AuthToken
    public ResponseResult add(OperationParam param) {
        return ResponseResultUtils.success(usService.add(param));
    }

    @DeleteMapping("/delete")
    @ApiOperation("取消关注")
    @AuthToken
    public ResponseResult delete(OperationParam param) {
        return ResponseResultUtils.success(usService.delete(param));
    }

    @GetMapping("/isAttention")
    @ApiOperation("是否已关注")
    public ResponseResult isAttention(OperationParam param) {
        return ResponseResultUtils.success(usService.isExist(param));
    }

}
